package net.edu_soft.ec.asset.service.impl;

import net.edu_soft.ec.asset.mapper.UserInfoMapper;
import net.edu_soft.ec.asset.pojo.UserInfo;
import net.edu_soft.ec.asset.pojo.UserInfoExample;
import net.edu_soft.ec.asset.pojo.bo.UserPermission;
import net.edu_soft.ec.asset.service.UserInfoService;
import net.edu_soft.ec.common.util.PagingDispose;
import net.edu_soft.ec.common.util.PuingUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import sun.net.www.ParseUtil;

import java.util.List;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userdao;

    @Override
    public long countByExample(UserInfoExample example) {
        return userdao.countByExample(example);
    }

    @Override
    public int deleteByExample(UserInfoExample example) {
        return 0;
    }

    @Override
    public int deleteByPrimaryKey(Integer userId) {
        return 0;
    }

    @Override
    public int insert(UserInfo record) {
        return userdao.insert(record);
    }

    @Override
    public int insertSelective(UserInfo record) {
        return userdao.insertSelective(record);
    }

    @Override
    public List<UserInfo> selectByExample(UserInfoExample example) {
        return userdao.selectByExample(example);
    }

    @Override
    public UserInfo selectByPrimaryKey(Integer userId) {
        return null;
    }

    @Override
    public int updateByExampleSelective(UserInfo record, UserInfoExample example) {
        return 0;
    }

    @Override
    public int updateByExample(UserInfo record, UserInfoExample example) {
        return 0;
    }

    @Override
    public int updateByPrimaryKeySelective(UserInfo record) {
        return 0;
    }

    @Override
    public int updateByPrimaryKey(UserInfo record) {
        return 0;
    }



    @Override
    public UserPermission selPermission(Integer roleId) {
        PuingUtil.notNullByZero(roleId,"查询权限：角色id不能为空或不能小于等于0");
        return userdao.selPermission(roleId);
    }

    @Override
    public UserInfo findByUserName(String username) {
        Assert.hasLength(username,"查询用户信息：用户名不能为空");
        return userdao.findByUserName(username);
    }

    @Override
    public List<UserInfo> getUserList() {
        UserInfoExample example = new UserInfoExample();
        List<UserInfo> list = userdao.selectByExample(example);//获取所有数据
        return list;
    }


}
